﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ChatDBAccess;

namespace Twitter
{
    public partial class Login : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void loginBtn_Click(object sender, EventArgs e)
        {
            int userId = ChatDBAccess.Login.LoginChecker(userNameBox.Text, passWordBox.Text);
            if (userId == -1)
            {
                ErrorUserNameLabel.Text = "Wrong username/password!";
            }
            else
            {
                ErrorUserNameLabel.Text = "";
                Session["userId"] = userId;
                Session["user"] = Search.FindUserById(userId);
                Response.Redirect("~/Index.aspx");   
            }

        }
    }
}